home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / graphics / rmtc02.zip / READDEF.C < prev    next >
Text File  |  1992-04-06  |  818b  |  54 lines

  1. #include <stdio.h>
  2. #include <graphics.h>
  3.  
  4. void main()
  5. {
  6.   FILE *F;
  7.   int driver = EGA;
  8.   int mode   = EGAHI;
  9.   int x, y, xoffset, yoffset;
  10.   int col, ch;
  11.  
  12.   if ((F=fopen("rm.def","r")) == NULL)
  13.   {
  14.     printf("Can't open file!\n");
  15.     exit(0);
  16.   }
  17.  
  18.   initgraph(&driver,&mode,"");
  19.  
  20.   setfillstyle(SOLID_FILL,BLUE);
  21.   bar(0,0,639,349);
  22.  
  23.   x=260;
  24.   y=120;
  25.   xoffset=0;
  26.   yoffset=0;
  27.  
  28.   while (!feof(F))
  29.    {
  30.     ch=fgetc(F);
  31.     if (ch=='\n')
  32.      {
  33.       xoffset=0;
  34.       yoffset++;
  35.      }
  36.     else
  37.      {
  38.       if (ch>47 && ch<58)
  39.        {
  40.     col=ch-48;
  41.     putpixel(x+xoffset,y+yoffset,col);
  42.        }
  43.       else if (ch>64 && ch<71)
  44.        {
  45.     col=ch-55;
  46.     putpixel(x+xoffset,y+yoffset,col);
  47.        }
  48.       xoffset++;
  49.      }
  50.     }
  51.   fclose(F);
  52.   getch();
  53.   closegraph();
  54. }